﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
        

        <script type="text/javascript">
        function init(){
            var btn = document.getElementById("btnGetFileName");
            btn.addEventListener("click", function (e) {
                var fileList = document.getElementById("fileDemo").files;
                //初始化reader、

                var reader = new FileReader();
                //读取文件里面的数据 异步的
                reader.readAsDataURL(fileList[0]);

                reader.onload = function (ev) {
                    var data = this.result;

                    $("#result").append("<img src='"+data+"'> </img>");
                };

            });
        }
        

        </script>
    </head>
    <body onload="init();">
        <input type="file" multiple id="fileDemo"/>
        <input type="button" id="btnGetFileName" onclick="alert(arguments[0]);" value="获取上去文件的名字"/>
        <div id="result">
            

        </div>
    </body>
</html>
